/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package tableCellRender;

import java.awt.Component;
import javax.swing.JTable;
import javax.swing.JTextField;
import static javax.swing.SwingConstants.CENTER;
import javax.swing.table.TableCellRenderer;
import otros.Util;

/**
 *
 * @author FERRETERIA
 */
public class Tipo implements TableCellRenderer  {
    private int filaSel;
    private boolean fuera;

    public Tipo (int fila, boolean fuera) {
        super();
        filaSel = fila;
        this.fuera = fuera;
    }
    
    @Override
    public Component getTableCellRendererComponent(final JTable jtable, Object value, boolean selected, boolean focused, int row, int column) {
        JTextField t = new JTextField();
        t.setBorder(null);
        t.setOpaque(true);
        t.setHorizontalAlignment(CENTER);
        if ( value != null) {
            String valor = "";
            switch ( (String) (value)) {
                case "00":
                    valor = "Fac/Contado";
                    break;
                case "01":
                    valor = "Fac/Credito";
                    break;
                case "10":
                    valor = "Alb/Contado";
                    break;
                case "11":
                    valor = "Alb/Credito";
                    break;
                case "20":
                    valor = "Abo/Contado";
                    break;
                case "21":
                    valor = "Abono/Credito";
                    break;    
            }
            t.setText(valor);
        } else
            t.setText("");
        t.setBackground(Util.getBackground(row,filaSel,jtable, selected, fuera));
        t.setForeground(Util.getForeground(row,filaSel,jtable,selected, fuera));          
        return t;
    }
}
